<template>
  <div class="games-container gradient-bg">
    <header class="header glass">
      <el-button @click="$router.back()" text>
        <el-icon><ArrowLeft /></el-icon>
        返回
      </el-button>
      <h2>趣味游戏</h2>
      <div style="width: 100px"></div>
    </header>

    <!-- 难度选择 -->
    <div class="difficulty-selector glass">
      <h3>选择难度范围</h3>
      <div class="difficulty-options">
        <div 
          class="difficulty-option"
          :class="{ active: selectedDifficulty === 'easy' }"
          @click="selectedDifficulty = 'easy'"
        >
          <div class="difficulty-icon">😊</div>
          <h4>简单模式</h4>
          <p>只包含当前年级的单词</p>
          <p class="tip">适合专注学习本学期内容</p>
        </div>
        
        <div 
          class="difficulty-option"
          :class="{ active: selectedDifficulty === 'medium' }"
          @click="selectedDifficulty = 'medium'"
        >
          <div class="difficulty-icon">🤔</div>
          <h4>中等模式</h4>
          <p>包含当前及上一学期单词</p>
          <p class="tip">巩固近期学习内容</p>
        </div>
        
        <div 
          class="difficulty-option"
          :class="{ active: selectedDifficulty === 'hard' }"
          @click="selectedDifficulty = 'hard'"
        >
          <div class="difficulty-icon">🔥</div>
          <h4>挑战模式</h4>
          <p>包含当前年级及以下所有单词</p>
          <p class="tip">全面复习，温故知新</p>
        </div>
      </div>
    </div>

    <div class="games-grid">
      <div class="game-card glass" @click="startGame('match')">
        <div class="game-icon">🎴</div>
        <h3>单词配对</h3>
        <p>找出单词和中文的正确配对</p>
        <el-tag type="success">益智</el-tag>
      </div>

      <div class="game-card glass" @click="startGame('rain')">
        <div class="game-icon">🌧️</div>
        <h3>单词雨</h3>
        <p>快速输入掉落的单词</p>
        <el-tag type="warning">反应</el-tag>
      </div>

      <div class="game-card glass" @click="startGame('puzzle')">
        <div class="game-icon">🧩</div>
        <h3>单词拼图</h3>
        <p>将字母拼成完整单词</p>
        <el-tag type="danger">挑战</el-tag>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { useRouter } from 'vue-router'
import { ArrowLeft } from '@element-plus/icons-vue'

const router = useRouter()
const selectedDifficulty = ref('hard') // 默认挑战模式

const startGame = (gameType: string) => {
  router.push(`/game/${gameType}?difficulty=${selectedDifficulty.value}`)
}
</script>

<style scoped lang="scss">
.games-container {
  width: 100%;
  min-height: 100vh;
  padding: 20px;
  overflow-y: auto;
  overflow-x: hidden;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 30px;
  margin-bottom: 40px;
  
  h2 {
    color: white;
    margin: 0;
    font-size: 1.5rem;
  }
}

.games-grid {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 30px;
  padding: 20px;
}

.game-card {
  padding: 40px 30px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
  
  &:hover {
    transform: translateY(-10px) scale(1.05);
    box-shadow: 0 15px 40px rgba(102, 126, 234, 0.5);
  }
  
  .game-icon {
    font-size: 5rem;
    margin-bottom: 20px;
    animation: bounce 2s ease-in-out infinite;
  }
  
  h3 {
    color: white;
    font-size: 1.8rem;
    margin: 15px 0;
  }
  
  p {
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 20px;
    font-size: 1.1rem;
  }
}

@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-15px);
  }
}

.difficulty-selector {
  max-width: 1200px;
  margin: 0 auto 40px;
  padding: 30px;
  
  h3 {
    color: white;
    text-align: center;
    font-size: 1.5rem;
    margin-bottom: 30px;
  }
}

.difficulty-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.difficulty-option {
  padding: 25px 20px;
  background: rgba(255, 255, 255, 0.05);
  border: 3px solid transparent;
  border-radius: 15px;
  cursor: pointer;
  transition: all 0.3s;
  text-align: center;
  
  &:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-5px);
  }
  
  &.active {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.2);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
  }
  
  .difficulty-icon {
    font-size: 3rem;
    margin-bottom: 15px;
  }
  
  h4 {
    color: white;
    font-size: 1.3rem;
    margin-bottom: 10px;
  }
  
  p {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.95rem;
    margin: 8px 0;
    
    &.tip {
      color: rgba(255, 255, 255, 0.6);
      font-size: 0.85rem;
      font-style: italic;
    }
  }
}
</style>
